import QtQuick 2.0

Item {
    property var namelist:[]
    signal unitClicked(string unitstring)

    Repeater {
        id: repeater
        model: namelist
        PhotoUnit {
            id: unit
            utext: namelist[index]
            ucolor: Qt.rgba(34/255,163/255,253/255,0.4+0.2*index)
            visible: false
            PathAnimation {
                id: pathAnimation
                target: repeater.itemAt(index)
                duration: 1500
                orientationEntryDuration: 500
                orientationExitDuration: 500
                easing.type: Easing.InCubic
                path: Path {
                    startX: 160
                    startY: 0
                    pathElements: PathArc {
                        x: Math.round(160+160*Math.sin((36+36*index)*Math.PI/180))
                        y: Math.round(160-160*Math.cos((36+36*index)*Math.PI/180))
                        useLargeArc: true
                        radiusX: 160
                        radiusY: 160
                        direction: PathArc.Counterclockwise
                    }
                }
            }
            MouseArea {
                anchors.fill: parent
                onClicked: {
                    unitClicked(unit.utext)
                }
            }
            function startPathAnimation(){
                pathAnimation.start();
            }
        }
    }

    function startParallelAnimation(){
        for(var i=0;i<repeater.count;i++){
            repeater.itemAt(i).startPathAnimation();
        }
    }

    function showUnit(){
        for(var i=0;i<repeater.count;i++){
            repeater.itemAt(i).visible = true;
        }
    }

    function hideUnit(){
        for(var i=0;i<repeater.count;i++){
            repeater.itemAt(i).visible = false;
        }
    }
}
